From 0b7f903b29f7046a4a9ff03770354cb0719de8a7 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Wed, 28 Sep 2005 13:43:07 +0100 Subject: [PATCH] Added behaviour to read() to read directly from the transaction's path if no arguments are specified. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/xenstore/xstransact.py | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py index 14d8b0472d..503136ad76 100644 --- a/tools/python/xen/xend/xenstore/xstransact.py +++ b/tools/python/xen/xend/xenstore/xstransact.py @@ -42,8 +42,15 @@ class xstransact: '%s, while reading %s' % (ex.args[1], path)) def read(self, *args): + """If no arguments are given, return the value at this transaction's + path. If one argument is given, treat that argument as a subpath to + this transaction's path, and return the value at that path. + Otherwise, treat each argument as a subpath to this transaction's + path, and return a list composed of the values at each of those + instead. + """ if len(args) == 0: - raise TypeError + return xshandle().read(self.path) if len(args) == 1: return self._read(args[0]) ret = [] @@ -191,6 +198,13 @@ class xstransact: def Read(cls, path, *args): + """If only one argument is given (path), return the value stored at + that path. If two arguments are given, treat the second argument as a + subpath within the first, and return the value at the composed path. + Otherwise, treat each argument after the first as a subpath to the + given path, and return a list composed of the values at each of those + instead. This operation is performed inside a transaction. + """ while True: t = cls(path) try: @@ -234,6 +248,12 @@ class xstransact: Remove = classmethod(Remove) def List(cls, path, *args): + """If no arguments are given (path), list its contents, returning the + entries therein, or None if no entries are found. Otherwise, treat + each further argument as a subpath to the given path, and return the + cumulative listing of each of those instead. This operation is + performed inside a transaction. + """ while True: t = cls(path) try: -- 2.30.2